<?php


	namespace app\lib\enums;


	class orderStatusEnums
	{
		//订单状态:0=待支付,1=已支付,待发货,2=已发货,待收货,3=已收货,待评论,5=已收货,已评论(完成),-1=取消

		//待支付
		const UNPAY    = 0;
		const UNPAYMSG = '待支付';
		//已支付
		const PAID    = 1;
		const PAIDMSG = '已支付';
		//已发货
		const  DELIVER    = 2;
		const  DELIVERMSG = '已发货';
		//已收货
		const  RECEIVED    = 3;
		const  RECEIVEDMSG = '已收货';
		//完成
		const COMPLETE    = 5;
		const COMPLETEMSG = '完成';
		//取消
		const CANCEL    = -1;
		const CANCELMSG = '取消';
		//全部
		const ALL    = 101;
		const ALLMSG = '全部';

		//文字描述
		public static function transStatusTxt ($status) {
			$txt = '';
			switch ($status) {
				case self::PAID;
					$txt = self::PAIDMSG;
					break;
				case self::DELIVER;
					$txt = self::DELIVERMSG;
					break;
				case self::RECEIVED;
					$txt = self::RECEIVEDMSG;
					break;
				case self::COMPLETE;
					$txt = self::COMPLETEMSG;
					break;
				case self::CANCEL;
					$txt = self::CANCELMSG;
					break;
				default;
					$txt = self::UNPAYMSG;
			}

			return $txt;
		}

		public static function statusList ($is_all = false) {

			$list = [
				['label' => self::UNPAY, 'value' => self::UNPAYMSG],
				['label' => self::PAID, 'value' => self::PAIDMSG],
				['label' => self::DELIVER, 'value' => self::DELIVERMSG],
				['label' => self::RECEIVED, 'value' => self::RECEIVEDMSG],
				['label' => self::COMPLETE, 'value' => self::COMPLETEMSG],
				['label' => self::CANCEL, 'value' => self::CANCELMSG],
			];

			if ($is_all) {
				array_unshift($list, ['label' => self::ALL, 'value' => self::ALLMSG]);
			}

			return $list;
		}

	}

